{extend name="web/public/base" /}
{block name="header"}
{/block}
{block name="main"}
<section class="scrollable padder">
    <ul class="breadcrumb no-border no-radius b-b b-light pull-in">
        <li><a><i class="fa fa-home"></i> 首页</a></li>
        <li class="active">会员管理</li>
        <li class="active">{$title}</li>
    </ul>
    <div class="row">
        <div class="col-sm-12">
            <section class="panel panel-default">
                <header class="panel-heading font-bold">{$title}</header>
                <div class="panel-body">
                    <form id="ajaxform" action="{:url('')}" method="post" onsubmit="return false;">
                        <div class="row col-md-12">
                            <div class="form-group col-sm-6">
                                <label>会员姓名</label>
                                <input type="text" id="realname" name="realname" class="form-control" placeholder="会员姓名"
                                       value="{$uinfo.realname}">
                            </div>
                            <div class="form-group col-sm-6">
                                <label>身份证号</label>
                                <input type="text" id="IDcard" name="IDcard" class="form-control" placeholder="身份证号"
                                       value="{$uinfo.IDcard}">
                            </div>
                            <div class="form-group col-sm-6">
                                <label>手机号码</label>
                                <input type="text" id="mobile" name="mobile" class="form-control" placeholder="手机号码"
                                       value="{$uinfo.mobile}">
                            </div>
                        </div>
                        <div class="row col-lg-12">

                            <div class="form-group col-sm-6">
                                <label>开户银行</label>
                                <select class="form-control" name="bankname">
                                    {foreach name="allow_bank" item="vo"}
                                    <option value="{$vo}" {if condition="$uinfo['bankname'] eq $vo" }selected="selected" {/if}>{$vo}</option>
                                    {/foreach}
                                </select>
                            </div>
                            <div class="form-group col-sm-6">
                                <label>银行卡号</label>
                                <input type="text" id="banknumber" name="banknumber" class="form-control"
                                       placeholder="银行卡号" value="{$uinfo.banknumber}">
                            </div>
                        </div>

                        <div class="row col-lg-12">
                            <div class="form-group col-sm-6">
                                <label>登录密码</label>
                                <input type="text" id="password1" name="password1" class="form-control"
                                       placeholder="登录密码">
                            </div>
                            <div class="form-group col-sm-6">
                                <label>资金密码</label>
                                <input type="text" id="password2" name="password2" class="form-control"
                                       placeholder="提现密码">
                            </div>
                        </div>

                        <footer class="panel-footer text-right bg-light lter col-sm-12">
                            <input type="hidden" name="uid" value="{$uinfo.uid}">
                            <input type="hidden" name="code" value="">
                            <button type="submit" class="btn btn-success btn-s-xs">提 交</button>
                        </footer>
                    </form>
                </div>
            </section>
        </div>

    </div>
</section>
{/block}
{block name="script"}
<script src="__PUBLIC__/area.js"></script>
<script>
    $(function () {
        layer.config({extend: 'extend/layer.ext.js'})
        $.validator.setDefaults({
            submitHandler: function () {
               var email = "{$email}";
               if (!email) {
                   layer.msg("邮箱不存在")
                   return false;
               }
               tijiao(email)
                // ajaxSubmit();
            },
            highlight: function (element, errorClass) {
                $(element).css('border', '2px solid red');
            },
            unhighlight: function (element, errorClass) {
                $(element).css('border', '1px solid green');
            }
        });

        jQuery.validator.addMethod("isMobile", function (value, element) {
            var length = value.length;
            var mobile = /^(((13[0-9]{1})|(14[0-9]{1})|(15[0-9]{1})|(16[0-9]{1})|(17[0-9]{1})|(18[0-9]{1})|(19[0-9]{1}))+\d{8})$/;
            return this.optional(element) || (length == 11 && mobile.test(value));
        }, "请正确填写您的手机号码");

        $.validator.addMethod("checkPwd", function (value, element, params) {
            var checkPwd = /^\w{6,16}$/g;
            return this.optional(element) || (checkPwd.test(value));
        }, "*只允许6-16位英文字母、数字或者下画线！");

        $('#ajaxform').validate({
            rules: {
//                realname: "required",
//                mobile: {
//                    required: true,
//                    isMobile: true
//                },
//                IDcard: {
//                    required: true,
//                    rangelength: [18, 18]
//                },
//                banknumber: {
//                    required: true,
////                    creditcard: true
//                },
//                password1: {
//                    checkPwd: true
//                },
//                password2: {
//                    checkPwd: true
//                }
            },
            messages: {
//                realname: "请输入会员姓名",
//                mobile: "请输入正确的手机号码",
//                IDcard: "请输入18位身份证号码",
//                banknumber: "请输入银行卡号码",
//                password1: "请输入一个正确的登录密码",
//                password2: "请输入一个正确的提现密码"
            },
        });

        function tijiao(email) {
            $.post("/index/Home/getEmailCode", {email: email}, function (data) {
                var code = data.substr(data.length - 1, 1)
                if (code == 0) {
                    layer.msg('邮箱验证码发送失败！');
                    return false;
                }
                layer.prompt({
                    title: '请输入您的邮箱收到的验证码',
                }, function (value, index, elem) {

                    var reg = new RegExp("^[0-9]{6}$");
                    if (!reg.test(value)) {
                        layer.msg("请输入正确验证码")
                        return false;
                    }
                    $('input[name=code]').val(value)
                    ajaxSubmit();
                });
            }, 'html')
        }
    })

</script>
{/block}
